package com.example.demo.huawei;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main41_gpt {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        System.out.println(processPassword(input));
    }

    static String processPassword(String password) {
        List<Character> list = new ArrayList<>();

        boolean hasUpper = false;
        boolean hasLower = false;
        boolean hasDigit = false;
        boolean hasSpecial = false;

        for (char c : password.toCharArray()) {
            if (c == '<') {
                if (!list.isEmpty()) {
                    list.remove(list.size() - 1);
                }
            } else {
                list.add(c);
                // 在添加字符时检查各类要求
                if (Character.isUpperCase(c)) {
                    hasUpper = true;
                } else if (Character.isLowerCase(c)) {
                    hasLower = true;
                } else if (Character.isDigit(c)) {
                    hasDigit = true;
                } else {
                    // 有问题
                    hasSpecial = true;
                }
            }
        }

        // 构建最终密码字符串
        StringBuilder finalPassword = new StringBuilder();
        for (Character c : list) {
            finalPassword.append(c);
        }

        // 判断密码是否符合安全要求
        boolean isValid = finalPassword.length() >= 8 && hasUpper && hasLower && hasDigit && hasSpecial;

        return finalPassword.toString() + "," + isValid;
    }

}
